package edu.pku.sei.transformation.qvt.adapter.standardqvt;

import edu.pku.sei.transformation.editor.model.MetaModel;
import edu.pku.sei.transformation.editor.model.ModelType;
import edu.pku.sei.transformation.editor.model.TypedModel;
import edu.pku.sei.transformation.qvt.rule.ITypedModel;

public class TypedModelAdapter implements ITypedModel {
	public TypedModel element;

	public TypedModelAdapter(TypedModel typedModel) {
		this.element = typedModel;
	}

	@Override
	public String getMetaModelName() {
		Object type = element.getType();
		if (type instanceof ModelType) {
			ModelType t = (ModelType) type;
			if (t.getType() instanceof MetaModel) {
				return ((MetaModel) t.getType()).getName();
			} else {
				return t.getName();
			}
		} else {
			System.out.println("model parameter with a invalid type");
			return "invalid";
			// throw new Exception("model parameter with a invalid type");
		}
	}

	@Override
	public String getName() {
		return element.getName();
	}

}
